package com.tz.online.book.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tz.online.book.service.IBookService;
import com.tz.online.entity.Book;
import com.tz.online.util.BeanFactory;

/**
 * 处理商品详情请求
 * @author Administrator
 *
 */
@WebServlet(name="detailBook",urlPatterns="/book/detailBook")
public class DetailBookAction extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3215033958120444117L;
	//通过bean工厂，获得service接口对象
	IBookService bs = (IBookService) BeanFactory.getBean("bookService");
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		//接收ID
		String bid = req.getParameter("bookId");
		
		//根据商品的标识，查询此商品信息
		Book book = bs.queryBookById(bid);
		req.setAttribute("book", book);
		//转发到视图显示
		req.getRequestDispatcher("/jsp/book/detail.jsp").forward(req, resp);
	}
}
